package Day2025_03_28;

import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt(), a = in.nextInt(), b = in.nextInt();
        if (n == 1 && m == 2) System.out.println(a);
        else if (n == 2 && m == 1) System.out.println(b);
        else {
            long[][] dp = new long[n + 1][m + 1];
            for (int i = 2; i <= n; i++) dp[i][1] = a;
            for (int i = 2; i <= m; i++) dp[1][i] = b;
            long ret = 0;
            for (int i = 2; i <= n; i++) {
                for (int j = 2; j <= m; j++) {
                    dp[i][j] = Math.max(dp[i - 2][j - 1] + a, dp[i - 1][j - 2] + b);
                    ret = Math.max(ret, dp[i][j]);
                }
            }
            System.out.println(ret);
        }
    }
}
